<template>
	<div id="app">
		<transition>
			<keep-alive>
				<router-view :key="key" />
			</keep-alive>
		</transition>
		<!-- <transition>
			<keep-alive>
				<router-view
					v-if="$route.meta.keepAlive"
				></router-view>
			</keep-alive>
		</transition>
		<transition>
			<router-view v-if="!$route.meta.keepAlive"></router-view>
		</transition> -->
	</div>
</template>

<script>
export default {
	name: 'App',
	data() {
		return {
			previousname: '',
			currentname: '',
		}
	},
	created() {
		window.onload = function() {
			// 阻止双击放大
			var lastTouchEnd = 0
			document.addEventListener('touchstart', function(event) {
				if (event.touches.length > 1) {
					event.preventDefault()
				}
			})
			document.addEventListener(
				'touchend',
				function(event) {
					var now = new Date().getTime()
					if (now - lastTouchEnd <= 300) {
						event.preventDefault()
					}
					lastTouchEnd = now
				},
				false
			)
			// 阻止双指放大
			document.addEventListener('gesturestart', function(event) {
				event.preventDefault()
			})
		}
	},
	computed: {
		key() {
			this.currentname = this.$route.name
			/*
					路由发生改变，清空params的缓存 
				*/
			if (
				this.previousname != '' &&
				this.previousname != null &&
				this.previousname != this.currentname
			) {
				window.localStorage.removeItem('params')
			}

			if (JSON.stringify(this.$route.params) !== '{}') {
				window.localStorage.setItem(
					'params',
					JSON.stringify(this.$route.params)
				)
			}
			this.previousname = this.$route.name
			return this.$route.fullPath
		},
	},
}
</script>

<style>
#app {
	width: 7.5rem;
	max-width: 750px;
	min-height: 100vh;
	margin: 0 auto;
}

/* 全局弹出框 */
.van-popup {
	background: transparent !important;
}

/* 限制一行 */
.limit-one-line {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-overflow: -o-ellipsis-lastline;
}

.limit-one-line input {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-overflow: -o-ellipsis-lastline;
}

/* 限制2行 */
.limit-two-line {
	overflow: hidden;
	text-overflow: ellipsis;
	text-overflow: -o-ellipsis-lastline;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
}

/* 富文本，最大字数 ，显示 */
.van-field__word-limit{
	color: #A3A3A3 !important;
}

.btn {
	width: 6.6rem;
	margin: 0 0.45rem;
	height: 0.8rem;
	border-radius: 0.16rem;

	background: #ffffff;
	color: #f7373b;

	text-align: center;
	font-size: 0.32rem;
	font-family: PingFangSC-Regular, PingFang SC;
	font-weight: 400;
	line-height: 0.8rem;
}

.main-btn {
	border-radius: 0.1rem;
	background: linear-gradient(270deg, #fe7a53 0%, #f7373b 100%);
	color: #ffffff;
}
</style>
